﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TibcoQueueMonitor.Entities
{
    /// <summary>
    /// Represents the object model of relevant TIBCO EMS administration data.
    /// </summary>
    [Serializable]
    public class TibcoAdministrationData
    {
        #region Private Fields
        private object _lockObject = new object();
        private bool _isTestData = false;

        private Dictionary<string, TibcoQueue> _queues;
        private Dictionary<string, TibcoConnection> _connections;
        private Dictionary<string, TibcoConsumer> _consumers;

        #endregion //Private Fields

        #region Public Properties
        /// <summary>
        /// Gets a value indicating whether this instance is test data.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is test data; otherwise, <c>false</c>.
        /// </value>
        public bool IsTestData
        {
            get { return _isTestData; }
        }

        /// <summary>
        /// Gets or sets the queues, indexed by queue name.
        /// </summary>
        /// <value>The queues.</value>
        public Dictionary<string, TibcoQueue> Queues
        {
            get { return _queues; }
            set { _queues = value; }
        }

        /// <summary>
        /// Gets or sets the connections, indexed by connection ID.
        /// </summary>
        /// <value>The connections.</value>
        public Dictionary<string, TibcoConnection> Connections
        {
            get { return _connections; }
            set { _connections = value; }
        }

        /// <summary>
        /// Gets or sets the consumers, indexed by connection ID.
        /// </summary>
        /// <value>The consumers.</value>
        public Dictionary<string, TibcoConsumer> Consumers
        {
            get { return _consumers; }
            set { _consumers = value; }
        }

        /// <summary>
        /// Gets the lock object used for multi-threaded synchronization.
        /// </summary>
        /// <value>The lock object.</value>
        public object LockObject
        {
            get { return _lockObject; }
        }

        #endregion //Public Properties

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="TibcoAdministrationData"/> class.
        /// </summary>
        public TibcoAdministrationData()
        {
            _queues = new Dictionary<string, TibcoQueue>();
            _connections = new Dictionary<string, TibcoConnection>();
            _consumers = new Dictionary<string, TibcoConsumer>();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TibcoAdministrationData"/> class.
        /// </summary>
        /// <param name="isTestData">if set to <c>true</c>, indicates that the
        /// data inside this container contains test data, not actual data
        /// retrieved from the specified EMS server.</param>
        public TibcoAdministrationData(bool isTestData) : this()
        {
            _isTestData = isTestData;
        }

        #endregion //Constructors
    }
}
